﻿using System.ServiceProcess;
using IScheduler.Core.Schedule.Monitor;

namespace IScheduler.Core.Schedule
{
    public partial class ScheduleService : ServiceBase
    {
        private ScheduleMonitor scheduleMonitor;

        public ScheduleService()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Start Service as Debug Mode when called from outside
        /// </summary>
        public void StartService()
        {
            try
            {
                this.scheduleMonitor.StartService();
            }
            catch
            {
                throw;
            }
        }
        /// <summary>
        /// Stop Service as Debug Mode when called from outside
        /// </summary>
        public void StopService()
        {
            try
            {
                this.scheduleMonitor.StopService();
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// Service Start
        /// </summary>
        /// <param name="args"></param>
        protected override void OnStart(string[] args)
        {
            try
            {
                StartService();
            }
            catch
            {

            }
        }

        /// <summary>
        /// Service Stop
        /// </summary>
        protected override void OnStop()
        {
            try
            {
                StopService();
            }
            catch
            {

            }
        }
    }
}
